/************************************************************************/
/*Copyright (c) James Zhao 2007,2008
/*This file is part of AdminOverlay.
/*AdminOverlay is free software: you can redistribute it and/or modify
/*it under the terms of the GNU General Public License as published by
/*the Free Software Foundation, either version 3 of the License, or
/*(at your option) any later version.
/*
/*AdminOverlay is distributed in the hope that it will be useful,
/*but WITHOUT ANY WARRANTY; without even the implied warranty of
/*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
/*GNU General Public License for more details.
/*
/*You should have received a copy of the GNU General Public License
/*along with Foobar.  If not, see <http://www.gnu.org/licenses/>.                                                                     */
/*************************************************************************/
#pragma once
#include "d3d9.h"
#include "QtCore/QtCore"
#include "GraphicsKit.h"
#include "UIOverlayRoot.h"

class EXPORT_UIKIT UIManager:  public LocatableVisual, public IRawInputListener
{
	Q_OBJECT
public:
	UIManager();
	~UIManager(void);
public:
	bool IsActive() const;
	void IsActive(bool val);	
	bool IsMouseDown() const;
	void IsMouseDown(bool val);
public:
	UIControl* getRoot();
	void draw(LPDIRECT3DDEVICE9 device);
	void onDeviceReset();
	static UIManager* currentInstance();

protected:
	//event overrides
	virtual void onRawKeyDown(int keyCode);
	virtual void onRawKeyUp(int keyCode);
	virtual void onRawMouseMove( QPoint point);
	virtual void onRawMouseDown( QPoint point);
	virtual void onRawMouseUp( QPoint point);

private:
	//active means the ui can recieve input. 
	QPoint mousePosition;
	static UIManager *instance;
	bool isActive;
	UIControl *root;
	QuadVisual *cursorQuad;
	bool isMouseDown;
	bool isCtrlDown;
	bool needCursorChange;
	bool wasCursorVisible;
};
